<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.ArrayList,Model.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Print Committees</title>
</head>
<body>
<%
	if (session.getAttribute("name") == null) {

		response.sendRedirect("nopermission.jsp");
	}
%>

<!-- Declare the first header -->
<jsp:include page="t_header.jsp" />


<jsp:include page="header.html" />


<!-- Declare sidebar -->
<jsp:include page="t_siderbarcommittee.jsp" />

<!-- Main Content -->
<section id="main" class="column">

	<!-- Message -->
	<%
		if (request.getParameter("error") != null) {
			if (request.getParameter("error").equals("1")) {
				out.print("<h4 class='alert_error'>No Committee selected.</h4>");
			} else if (request.getParameter("error").equals("2")) {
				if (request.getParameter("action").equals("approved")) {
					out.print("<h4 class='alert_success'>Committee approved.</h4>");
				} else if (request.getParameter("action")
						.equals("rejected")) {
					out.print("<h4 class='alert_success'>Committee rejected.</h4>");
				}

			}

		}
	%>

	<article class="module width_full">
		<header>
			<h3>Pending Committees</h3>
		</header>
	<script>
			$(document).on('change','input[name="checkall"]',function() {
				if($('input[name="committeeID"]').is(':checked'))
					{
						$('input[name="committeeID"]').attr('checked',false);
					}
				else{
				$('input[name="committeeID"]').prop("checked",this.checked);
				}
			});
	</script>
		<form action="CommitteeChangeStatus" method="POST">
			<input type="submit" name="action" value="Approve" /><input
				type="submit" name="action" value="Remove" />

			<table class="tablesorter" cellspacing="0">
				<thead>
					<tr>
						<th style="width: 2%"><input type="checkbox" name="checkall" value="checkall"/></th>
						<th style="width: 13%">Title</th>
						<th style="width: 23%">Purpose</th>
						<th style="width: 13%">Role</th>
						<th style="width: 13%">Staff</th>
						<th style="width: 3%">Effective Date</th>
						<th style="width: 3%">Action</th> 
					</tr>
				</thead>
				<tbody>
				<% 
					ArrayList<Committee> commArr = new ArrayList<Committee>();
					Committee com = new Committee();
					commArr = Committee.getApprovedCommittees();
					for(int i = 0; i < commArr.size(); i++)
					{
						com = commArr.get(i);
						ArrayList<String> staffName = com.getStaffList();
						ArrayList<String> roleList = com.getRoles();
				 %>
				 <tr>
				 	<td><input type="checkbox" name="committeeID" value='<%= commArr.get(i).getId() %>'/></td>
				 	<td><%= com.getTitle() %></td>
				 	<td><%= com.getPurpose() %></td>
				 	<td><% for (int q = 0; q < roleList.size();q++){%>
					<%= roleList.get(q) %><br/>
					<% } %>
					</td>
				 	<td>
				 	<% 
				 		for(int j = 0; j < staffName.size(); j++){
				 	%>
				 	<%= staffName.get(j) %><br/>
				 	<% } %>
				 	</td>
				 	<td><%= com.getDate() %></td>
					<td><a target="_blank" href="CommitteePrint?id=<%= com.getId() %>">Print</a></td> 
				 </tr>
				 <%} %>
 				</tbody>
			</table>
		</form>



	</article>

	<!-- end of content manager article -->
	<div class="spacer"></div>
</section>

<!-- Declare closing tags -->
<jsp:include page="t_footer.jsp" />
</body>
</html>